package com.github.wxiaoqi.security.auth.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.github.wxiaoqi.security.auth.biz.ClientBiz;
import com.github.wxiaoqi.security.auth.entity.Client;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;

/**
 * @author ace
 * @create 2017/12/26.
 */
@RestController
@RequestMapping("service")
public class ServiceController extends BaseController<Client>{
	
	@Autowired
	private ClientBiz clientBiz;

    @RequestMapping(value = "/{id}/client", method = RequestMethod.PUT)
    public ObjectRestResponse<Boolean> modifyUsers(@PathVariable int id, String clients){
        clientBiz.modifyClientServices(id, clients);
        return new ObjectRestResponse<Boolean>().rel(true);
    }

    @RequestMapping(value = "/{id}/client", method = RequestMethod.GET)
    public ObjectRestResponse<List<Client>> getUsers(@PathVariable int id){
        return new ObjectRestResponse<List<Client>>().rel(true).data(clientBiz.getClientServices(id));
    }

	@Override
	protected BaseBiz<Client> getBaseBiz() {
		return clientBiz;
	}
}
